package com.cloud.drore.eboss.supplier.mapper;

import com.cloud.drore.eboos.common.base.MyMapper;
import com.cloud.drore.eboos.common.entity.supplier.Ticket;
import com.cloud.drore.eboos.common.entity.supplier.po.TicketQueryPo;
import com.cloud.drore.eboos.common.entity.supplier.vo.TicketAllVo;
import com.cloud.drore.eboss.supplier.entity.vo.RejectInfoVo;
import com.cloud.drore.eboss.supplier.mapper.provider.TicketProvider;
import org.apache.ibatis.annotations.*;

import java.util.List;


/**
 * 浙江卓锐科技股份有限公司 版权所有  Copyright 2018<br>
 *
 * @Description: <br>
 * @Project: eboos <br>
 * @CreateDate: Created in 2018/1/8 10:36 <br>
 * @Author: <a href="575842778@qq.com">郑永涛</a>
 */
public interface TicketMapper extends MyMapper<Ticket> {

    static String selectExpiredTicketSql = " SELECT id,common_product_id FROM eboos_ticket WHERE is_deleted =0 AND NOW() > term_of_validity_end_time ";

    @SelectProvider(type = TicketProvider.class, method = "findTicketByParam")
    List<TicketAllVo> findTicketByParam(TicketQueryPo ticketQueryPo);

    @SelectProvider(type = TicketProvider.class, method = "findTicketListWithoutExpired")
    List<TicketAllVo> findTicketListWithoutExpired(TicketQueryPo ticketQueryPo);

    @SelectProvider(type = TicketProvider.class, method = "selectTicketById")
    TicketAllVo selectTicketById(Long ticketId);

    @Update("update eboos_ticket set status ='${status}' where id =${id} ")
    int rejectProduct(@Param("id") Long id, @Param("status") String status);

    @UpdateProvider(type = TicketProvider.class, method = "updateTicketByParam")
    int updateTicketByParam(Ticket ticket);

    @SelectProvider(type = TicketProvider.class, method = "selectTicketByProNum")
    TicketAllVo selectTicketByProNum(String proNumber);

    @SelectProvider(type = TicketProvider.class, method = "selectRejectInfoByProId")
    RejectInfoVo selectRejectInfoByProId(Long productId);

    @Select(selectExpiredTicketSql)
    List<TicketAllVo> selectExpiredTicket();

    @SelectProvider(type = TicketProvider.class, method = "findTicketByParamDealer")
    List<TicketAllVo> findTicketByParamDealer(TicketQueryPo ticketQueryPo);
}
